<script setup lang="ts">
import { onReachBottom, onLoad } from '@dcloudio/uni-app';
import ICard from '../components/card.vue';
import { apiFansist, addFollow, delFollow } from '@/apis/fans';
import { ref } from 'vue';
import cardBox from './components/card.vue';

let pageNum = ref(1);
let pageSize = ref(10);
let fansLists = ref([]);
let total = ref(0); //粉丝总数
let isMore = ref(false)

// 粉丝榜
const getFansList = async () => {
  let res = await apiFansist({ pageNum: pageNum.value, pageSize: pageSize.value });
  total.value = res.total;

  if (res.rows.length <= 0) {
    isMore.value = true;
    if (pageNum.value == 1) {
      fansLists.value = []
    }
    return false;
  }


  for (let i = 0; i < res.rows.length; i++) {
    fansLists.value = res.rows;
  }

}



onLoad(async () => {
  getFansList();
})

onReachBottom((e: any) => {
  if (!isMore.value) {
    pageNum.value++;
  }
  getFansList();
})

</script>
<template>
  <view class="main">
    <view class="my-fans">
      我的粉丝({{ total }}人)
    </view>

    <view class="fans-list">
      <ICard type="fans" :lists="fansLists" @childFansList="getFansList"></ICard>
    </view>
    <noneBox v-if="fansLists.length <= 0"></noneBox>

  </view>
</template>

<style scoped lang="scss">
.main {
  .my-fans {
    font-weight: 800;
    padding: 20rpx 40rpx;
    font-size: 28rpx;
  }

  .fans-list {
    background-color: #ffffff;
  }



}
</style>
